<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>已结项</title>
    <c:import url="../../header.jsp"/>
    <link rel="stylesheet" href="${rootUrl}/static/css/time-status-color.css?v=${version}">
    <style>
        table.crm-table.cell-border tbody td{
            white-space: nowrap;
        }
    </style>
</head>
<body>
<div class="body-main">
    <%--搜索条件--%>
    <div class="titleSearch">
        <%-- <div class="layui-inline">
             <label>生产订单编号：</label>
             <div class="layui-input-inline">
                 <input name="scProductOrderNo" type="text" class="input-style" maxlength="50"/>
             </div>
         </div>--%>
        <div class="layui-inline">
            <label>业务类型：</label>
            <div class="layui-input-inline">
                <div id="business_typeCode">
                    <input type="hidden" name="typeCodeId" class="plug-in-msg"/>
                    <input type="hidden" name="typeCode" id="typeCode" class="plug-in-code"/>
                    <input type="text" readonly placeholder="请选择业态" class="chose-plugIn layui-input"
                           name="businessTypeName">
                    <div class="bus-picker">
                        <div class="bus-picker-tab">
                            <a href="javascript:void(0);" class="active">请选择业态</a>
                        </div>
                        <div class="bus-picker-content"></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-inline">
            <label>订单来源：</label>
            <div class="layui-input-inline">
                <select class="select-style" id="signOrgId" name="signOrgId">
                </select>
            </div>
        </div>
            <div class="layui-inline">
                <label>客户电话：</label>
                <div class="layui-input-inline">
                    <input name="customerPhone" type="text" class="input-style" maxlength="50"
                           placeholder="请输入编号">
                </div>
            </div>
            <div class="layui-inline">
                <label>签单时间：</label>
                <div class="layui-inline">
                    <input type="text" name="signTimeStart" placeholder="开始时间" class="Wdate input-style" id="d4311"
                           onFocus="var d4312=$dp.$('d4312'); WdatePicker({onpicked:function(){d4312.focus();}, maxDate:'#F{ $dp.$D(\'d4312\')}', dateFmt:'yyyy-MM-dd'})">
                </div>
                <span>~</span>
                <div class="layui-inline">
                    <input type="text" name="signTimeEnd" placeholder="结束时间" class="Wdate input-style" id="d4312"
                           onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}', dateFmt:'yyyy-MM-dd'})">
                </div>
            </div>
            <div class="layui-inline">
                <label>超期状态：</label>
                <div class="layui-input-inline">
                    <select id="cq_status" name="cq_status">
                        <option value>请选择</option>
                        <option value="1">订单超期</option>
                        <option value="2">节点超期</option>
                    </select>
                </div>
            </div>
        <div class="layui-inline" style="margin-left: 10px">
            <label>流程人员：</label>
            <div class="layui-input-inline select2-inline">
                <select class="select-style" name="flowUserId" id="flowUserId" flowuser-select-law>
                    <option value>请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label>关键词：</label>
            <div class="layui-input-inline">
                <input name="keyWords" type="text" class="input-style" style="width: 300px;"
                       placeholder="客户名称/生产订单编号/订单编号/企业名称/合同编号"/>
            </div>
        </div>
        <div class="layui-inline">
            <label>完结时间：</label>
            <div class="layui-input-inline">
                <input style="width: 120px" type="text" name="completedTimeStart" placeholder="开始时间" class="Wdate input-style" id="completedTimeStart"
                       onfocus="var endDate=$dp.$('completedTimeStart'); WdatePicker({onpicked:function(){endDate.focus();}, dateFmt:'yyyy-MM-dd'})">
            </div>
            <div class="layui-input-inline">
                <input style="width: 120px" type="text" name="completedTimeEnd" placeholder="结束时间" class="Wdate input-style" id="completedTimeEnd"
                       onfocus="var endDate=$dp.$('completedTimeEnd'); WdatePicker({onpicked:function(){endDate.focus();}, dateFmt:'yyyy-MM-dd'})">
            </div>
        </div>
        <div class="layui-inline">
            <label>结项时间：</label>
            <div class="layui-input-inline">
                <input style="width: 120px" type="text" name="overEndTimeStart" placeholder="开始时间" class="Wdate input-style" id="overEndTimeStart"
                       onfocus="var endDate=$dp.$('overEndTimeStart'); WdatePicker({onpicked:function(){endDate.focus();}, dateFmt:'yyyy-MM-dd'})">
            </div>
            <div class="layui-input-inline">
                <input style="width: 120px" type="text" name="overEndTimeEnd" placeholder="结束时间" class="Wdate input-style" id="overEndTimeEnd"
                       onfocus="var endDate=$dp.$('overEndTimeEnd'); WdatePicker({onpicked:function(){endDate.focus();}, dateFmt:'yyyy-MM-dd'})">
            </div>
        </div>

        <div class="layui-inline">
            <button class="layui-btn layui-btn-mini layui-btn-normal" onclick="dataTableReload()">搜索</button>
            <button class="layui-btn layui-btn-mini layui-btn-primary" onclick="clearSearchKeys()">清空</button>
            <button class="layui-btn layui-btn-mini layui-btn-green" onclick="export_data()">导出</button>
        </div>
    </div>
    <%--按钮操作--%>
    <div class="table-conter">
        <div class="fr other-span">
            <div class="fr">
                <span class="bgBlueGreen">合同超期</span>
                <span class="bgRed">订单超期</span>
                <span class="bgBlue">节点超期</span>
            </div>
        </div>
    </div>
    <%--列表展示--%>
    <div class="table-body">
        <table id="myTable" class="cell-border crm-table columnsHidden dataTable">
            <colgroup>
                <col width="20">
                <col width="50">
            </colgroup>
        </table>
    </div>
</div>

<c:import url="/WEB-INF/jsp/footer.jsp"/>
<script src="${basePath}/static/js/zzsc/production/sc_common.js?v=${version}" type="text/javascript"
        charset="utf-8"></script>
<script type="text/javascript"
        src="${basePath}/static/js/zzsc/production/sc_flowuser.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/choose.extend.js?v=${version}"></script>
<script type="text/javascript" src="${basePath}/static/js/zzsc/common/call_common.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/zzsc/inprocess/inprocess_list.js?v=${version}"></script>
<script type="text/javascript">
    syb("#signOrgId");//初始化事业部
    var table = null, paras = null;
    $(document).ready(function () {
        //业务类型
        Plug.plug_in("post", "${basePath}/zzsc/common/tree_book_list.do?code=BUS_YT_ZZ&&type=2&&level=2", "#business_typeCode", '选择业态', '', true, 'BUS_YT_ZZ', '', '');
        //根据code加载下拉项
        $("select[code]").loadSelectOptions();
        //活动标签,并指定click事件
        $(".title-tab").activeTab({
            fn: function (e) {
                var val = $(e).attr("data");
                var code = $(e).attr("code");
                var $container_status = $("#filter-status");
                var $container_reason = $("#reason-filter");
                var $status = $container_status.find("select").eq(0);
                var $reason = $container_reason.find("select").eq(0);
                if (val == "") {
                    $status.removeAttr("fixed");
                    $container_status.show();
                    $container_reason.hide();
                } else {
                    $status.attr("fixed", true);
                    $container_reason.show();
                    $container_status.hide();
                }
                cleanSearch();
                //设置状态
                $status.val(val);
                //清空原因select option
                $reason.empty();
                $reason.html('<option value="">请选择</option>');
                $reason.attr("code", code);
                $($reason).loadSelectOptions();
                $('#myTable').dataTableExtend("reloadFalse");
            }
        });
        //初始化dataTable列表
        table = $('#myTable').dataTableExtend({
            "ajax": {
                "url": "/zzsc/junctions/query_junctions_list.do",
                "type": "post"
            },
            "fnServerParams": function (aoData) {
                var paras = $('.titleSearch').serialize2object();
                aoData = $.extend(aoData, paras);
                return aoData;
            },
            "scrollX": "true",//是否开启横项滚动
            "fixedColumns": {//锁定列，只有开启scrollX时才生效
                "leftColumns": 4,//左侧锁定2列
                "rightColumns": 1//右侧锁定1列
            },
            "aoColumns": [
                {
                    "orderable": false,
                    "data": "id",
                    "render": function (data, type, full, meta) {
                        return '<input type="checkbox"  name="ids" class="checkchild"  value="' + data + '" />';
                    }
                }
                , {
                    "title": "序号",
                    "orderable": false,
                    "render": function (data, type, full, meta) {
                        return meta.row + 1;
                    }
                }, {
                    "title": "订单来源",
                    "orderable": false,
                    "data": "signOrgName"
                }, {
                    "title": "生产订单编号",
                    "orderable": false,
                    "data": "scProductOrderNo",
                    "render": function (data, type, row) {
                        {
                            return '<a href="javascript:;"  class="layui-table-link" onclick="openOrderInfoDetail(\'' + row.scProductOrderNo + '\',\'' + row.id + '\')" /><p>' + data + '</p></a>';
                        }
                    }
                }, {
                    "title": "订单编号",
                    "orderable": false,
                    "data": "orderNo",
                    "render": function (data, type, full, meta) {
                        return ('<a href=\'javascript:void(0)\' ti  onclick="openBusinessDetail(\'' + full.orderNo + '\',\'' + full.orderId + '\')" /><span class="layui-table-link">' + data + '</span></a>&nbsp;');
                    }
                }, { //合同编号
                    "title": "合同编号",
                    "orderable": false,
                    "data": "contractNo"
                },{
                    "title": "客户",
                    "orderable": false,
                    "data": "customerName",
                    "render": function (d, type, r) {
                        return d + '<p>' + r.customerPhone + '</p>';
                    }
                }, {
                    "title": "业务类型",
                    "orderable": false,
                    "data": "businessProductName"
                }, {
                    "title": "产品类型",
                    "orderable": false,
                    "data": "productName"
                }, {
                    "title": "销售订单备注",
                    "orderable": false,
                    "data": "orderRemark",
                    "render": function (data, type, full, meta) {
                        if(data){
                            return  '<div class="line2" style="min-width: 120px" title="'+data+'">'+data+'</div> ';
                        }else{
                            return '';
                        }
                    }
                }, {
                    "title": "签单时间",
                    "orderable": true,
                    "data": "signTime"
                }, {
                    "title": "签单商务",
                    "orderable": false,
                    "data": "signUserName"
                },
                { //签单部门
                    "title": "签单部门",
                    "orderable": false,
                    "data": "signUserOrgName"
                },
                { //流程人员
                    "title": "流程人员",
                    "orderable": false,
                    "data": "flowUserName"
                },
                { //流程部门
                    "title": "流程部门",
                    "orderable": false,
                    "data": "flowUserOrgName"
                },
                { //生产负责人
                    "title": "生产负责人",
                    "orderable": false,
                    "data": "productUserName",
                    "render": function (data, type, full, meta) {
                        if(data) {
                            return full.productUserName+'<p>'+full.productUserOrgName+'</p>';
                        }else{
                            return '';
                        }
                    }
                },{
                    "title": "企业名称",
                    "orderable": false,
                    "data": "companyName",
                    "render": function (data, type, full, meta) {
                        (data==null)&&(data='');
                        return '<div class="line2" style="min-width: 50px" title="'+data+'">'+data+'</div> ';
                    }
                },{
                    "title": "完结时间",
                    "orderable": false,
                    "data": "completedTime",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },{
                    "title": "结项时间",
                    "orderable": false,
                    "data": "overEndTime",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },{
                    "title": "操作",
                    "orderable": false,
                    "data": "id",
                    "render": function (d, type, r, meta) {
                        var result = "";
                        result += '<a href=\'javascript:void(0)\' ti  onclick="callPhoneByProduction(\'' + r.id + '\')" /><span style="color: #0066ff; font-weight: bold " ">打电话</a>&nbsp;&nbsp;&nbsp;';
                        result += '<a href=\'javascript:void(0)\' class="layui-table-link" onclick="remarkLayer(\'' + r.id + '\')" /><span style="color: #0066ff; font-weight: bold " ">备注</a>&nbsp;';
                        return result;
                    }
                }],
            "columnDefs": [{
                targets: [0],
                createdCell: function (td, cellData, rowData, row, col) {
                    var nodestatus = rowData.nodeTimeStatus;
                    var orderstatus = rowData.orderTimeStatus;
                    if ("OVERDUE_STATE2" == rowData.contractTimeStatus) {
                        $(td).parent().addClass("bgBlueGreen");
                        return;
                    }
                    if ("OVERDUE_STATE2" == orderstatus) {
                        $(td).parent().addClass("bgRed");
                        return;
                    }
                    if ("OVERDUE_STATE2" == nodestatus) {
                        $(td).parent().addClass("bgBlue");
                        return;
                    }
                }
            },
                {
                    targets: ["_all"], "defaultContent": ""
                }
            ]
        });

    });

    function export_data() {
        var paras = $('.titleSearch').serialize2object();
        if (Object.keys(paras).length == 0) {
            DGG.Warning('请加入搜索条件后导出！');
            return;
        }
        $.extend(paras, {type: $(".title-tab").find("a.active").attr("data-status")});
        exportDataAbandoned('/zzsc/junctions/export_product_order.do', paras);
    }

</script>
</body>

</html>